<?php


class Project_leader
{


function showHeader($user)
	{
?>
	<html>
	<head>
		<title>Task Management Software ::Project Leader</title>
		<script type="text/javascript" src="js/dropdowntabs.js"></script>
		<script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script>
		<script type="text/javascript" src="js/project_leader.js"></script>
		
		<link href="jquery/jquery-ui.css" rel="stylesheet" type="text/css"/>
		
		<script src="jquery/jquery-ui.js"></script>
		<script src="jquery/date.js"></script>


		<link rel="stylesheet" type="text/css" href="css/ddcolortabs.css"/>
		<link rel="stylesheet" href="css/new.css" />
    </head>
	<body>
		<div id="wrapper"><!--wrapper-->
			<div id="header"><!--header-->
				<div id="logo">Task Management
				</div>				
				<div id="homlog">
					<img src="images/home.gif" width="20" height="20"/>
					<a href="logout.php"><img src="images/logout.png" width="20" height="20" border=0/></a>
				</div>
				<div id="user">
					Logged as :<?php echo $user->getUserName(); ?><br/>User Type : <?php echo $user->getUserType(); ?>
				</div>
			</div><!--header-->

<?php
	}





function showTable($pid,$task)
{
?>

<table  width="100%" id="hd" cellpadding="0" cellspacing="0" >

<tr>
<th><input type="checkbox" id="maincheckbox" onclick="toggleCheck(this)"/></th>
<th class="linky" name="task_name" onclick="sorty(this)">Task</th>
<th class="linky" id="des" name="task_description" onclick="sorty(this)">Description</th>
<th class="linky" id="mod_id" name="project_modules_id" onclick="sorty(this)">Module224</th>
<th class="linky" id="mod_id" name="onwer_id" onclick="sorty(this)">Onwer</th>
<th class="linky" id="mod_id" name="assignee_id" onclick="sorty(this)">Assignee</th>
<th class="linky" name="starting_date" onclick="sorty(this)">Start Date</th>
<th class="linky" name="deadline" onclick="sorty(this)">Due Date</th>
<th class="linky" name="priority" onclick="sorty(this)">Priority</th>
<th class="linky" name="status" onclick="sorty(this)">Status</th>
<th class="linky" style="width:10%;line-height:15px" name="percentage_completed" onclick="sorty(this)">%<BR/>Completed</th>
</tr>

<?php
					if(sizeof($task)==0)
					{
						echo "<tr><td colspan='8'>No Records Found ....... !</td></tr>";
					}
					else
					{
							foreach($task as $t)
								{						
									$tobj = new Task($t);

									echo "<tr>";
									echo "<td><input type='checkbox' id='$t' name='tcheckbox' /></td>";
									echo "<td>".$tobj->getTaskName()."</td>";
									echo "<td>".$tobj->getTaskDescription()."</td>";
									echo "<td>";
										$mod_id = $tobj->getTaskModuleId();
										echo TMSFunctions::getModuleNameFromId($mod_id);
									echo "</td>";

									echo "<td>";
									$own_id = $tobj->getTaskOwner();
									$usr1 =new User($own_id);
									echo $usr1->getFirstName();
									echo "</td>";
									echo "<td>";
									$assign_id = $tobj->getTaskAssignee();
									$usr2 =new User($assign_id);
									echo $usr2->getFirstName();
									echo "</td>";

									echo "<td>".$tobj->getTaskStartDate()."</td>";
									echo "<td>".$tobj->getTaskDeadline()."</td>";
									echo "<td>".$tobj->getTaskPriority()."</td>";
									echo "<td id='status$t'>".$tobj->getTaskStatus()."</td>";
									echo "<td id='percentage$t'>";
									if($tobj->getTaskStatus()=='CLOSED')
									echo"<button class='openbtn' onclick='openTask($t)'>Open Task</button>";
									else
									echo $tobj->getTaskPercentage();
									echo"</td>";
									echo "</tr>";
								}
					}
							?>
						
						</table>

<?php
}

function showProjectsTable($projects)
{
?>

<table  width="100%" id="hd" cellpadding="0" cellspacing="0" >

<tr>
	<th><input type="checkbox" id="maincheckbox" onclick="toggleCheck(this)"/></th>
	<th class="linky" name="task_name" onclick="sorty2(this)">Name</th>
	<th class="linky" id="des" name="task_description" onclick="sorty2(this)">Description</th>
	<th class="linky" name="starting_date" onclick="sorty2(this)">Client</th>
	<th class="linky" name="deadline" onclick="sorty2(this)">Start Date</th>
	<th class="linky" name="priority" onclick="sorty2(this)">Deadline</th>

</tr>

<?php
					if(sizeof($projects)==0)
					{
						echo "<tr><td colspan='8'>No Records Found ....... !</td></tr>";
					}
					else
					{
							foreach($projects as $p)
								{						
									$pobj = new Project($p);

									echo "<tr id='tr$p' onclick='ds(this)'>";
									echo "<td><input type='checkbox' id='$p' name='tcheckbox' /></td>";
									echo "<td>".$pobj->getProjectName()."</td>";
									echo "<td>".$pobj->getDescription()."</td>";
									$cid = $pobj->getClientId();
									$cobj = new Client($cid);
									echo "<td>".$cobj->getClientName()."</td>";
									echo "<td>".$pobj->getStartingDate()."</td>";
									echo "<td>".$pobj->getDeadline()."</td>";
									echo "</tr>";
									echo "<tr id='det' class='hide'><td colspan='6'><pre>";
									echo $pobj->getTasksByStatus($p)." : Total Tasks <br/>";
									echo $pobj->getTasksByStatus($p,"completed")." : Completed Tasks <br/>";
									echo $pobj->getTasksByStatus($p,"open")." : Opened Tasks <br/>";
									echo $pobj->getTasksByStatus($p,"closed")." : Tasks Not Assigned <br/>";
									echo $pobj->getTasksByStatus($p,"drop")." : Dropped Tasks <br/>";
									echo $pobj->getTasksByStatus($p,"deferred")." : Deferred Tasks <br/>";
									echo $pobj->getTasksByStatus($p,"require_assistance")." : Require's Assistance <br/>";
									echo"</td></tr>";
								}
					}
							?>
						
						</table>

<?php
}


function showAddTaskTable($pid)
	{
		$pobj = new Project($pid);
	$members = $pobj->getMembers();
	$priorityFields="--PRIORITY--,HIGH,NORMAL,LOW";
	$modules=$pobj->getModules();
								
	
?>

	<a id="Closebtn_tsk" class="pointer" onclick="closePopup('popupAddTask')">x</a>

						<h1 style="color:#1D4A7F;text-align:center">ADD TASK</h1>
							<table id="addtab"  align=center cellpadding=5 cellspacing=5 style="width:75%">
								<tr>
									<td>Task Name</td>
									<td><input type="text" name="tname" id="taddName" maxlength="35" size="35" /></td>
								</tr>
								<tr>
									<td>Description</td>
									<td><textarea rows="3" cols="28" id="taddDesc"></textarea></td>
								</tr>
								<tr>
									<td>
									Assignee :<?php
							echo TMSFunctions::generateSelectFromDb($members,"tms_users","id","first_name","id","","--USER--","","","","taddAssignee");
							?>
									</td>
									<td>
									Priority :	<?php
							 echo TMSFunctions::generateSelect($priorityFields,$priorityFields,"","","","","taddPriority");


							?>
									</td>
								</tr>
								<tr>
									<td>
									Deadline :<input type="text" id="taddDeadline" value="<?php echo date('Y-m-d')?>" name="deadline" maxlength="11" size="10" />
									</td>
									<td>
									Module :	
									<?php
							echo TMSFunctions::generateSelectFromDb($modules,"tms_project_modules","id","module_name","id","","--MODULES--","","","","taddModule");
							?>
									</td>
								</tr>
								<tr>
									<td colspan="2" style="text-align:center;"><button onclick="addTask()">ADD</button>&nbsp;<button onclick="reset()">RESET</button></td>									
								</tr>
																		
							</table><div id='tmsg' class='no2'> </div>

							<?php



	}


function showReqExnTable()
	{

	?>

	<a id="Closebtn_ext" class="pointer" onclick="closePopup('popup_ex')">x</a>

						<h1 style="color:#1D4A7F;text-align:center;">REQUEST EXTENSION</h1>
							<table id="reqtab"  align="center" cellpadding="5" cellspacing="5" style="width:75%">
								<tr>
									<td>Task</td>
									<td>Task1, Task2</td>
								</tr>
								<tr>
									<td>Progress</td>
									<td>30% SLOW</td>
								</tr>
								<tr>
									<td>Extention needed-(in days)</td>
									<td><input type="text" name="" maxlength="35" size="35"></td>
								</tr>
								<tr>
									<td style="vertical-align:top;">Reason for Extension-(if any)</td>
									<td><textarea rows="3" cols="28" name="">dd</textarea></td>
								</tr>
								<tr>
									<td colspan="2"style="text-align:center;"><button>REQUEST</button>&nbsp;<button onclick="closePopup('popup_ex')">CANCEL</button>	
									</td>
								</tr>
							</table>

							<?php



	}





function showProfileTable($user)
{
	?>
	<h2 class="center">PROFILE DETAILS</h2>
			<a class="pointer Closebtn2" onclick="closePopup('profilePopup')">x</a>
			<table border=1 align="center" class="protab" cellspacing="5" cellpadding="5" style="width:75%">
				<tr>
					<td>Username</td><td><?php echo $user->getUserName();?></td>
				</tr>
				<tr>
					<td>First Name</td><td><?php echo $user->getFirstName();?></td>
				</tr>
				<tr>
					<td>Last Name</td><td><?php echo $user->getLastName();?></td>
				</tr>
					<tr>
					<td>Email</td><td><?php echo $user->getEmail();?></td>
				</tr>
				<tr>
					<td>Designation</td><td><?php echo TMSFunctions::getDesignationFromId($user->getDesignationId());?></td>
				</tr>
				<tr>
					<td>UserType</td><td><?php echo $user->getUserType();?></td>
				</tr>
				<tr>
					<td>Last login</td><td><?php echo $user->getLastLogin();?></td>
				</tr>
				<tr>
					<td style="text-align:center" colspan="2">
						<button  onclick="edit()">EDIT</button>&nbsp;
						<button onclick="closePopup('profilePopup')">CANCEL</button>&nbsp;
					</td>
				</tr>
			</table>
			<?php
}

function editProfileTable($user)
{
	?>
	<h2 class="center">PROFILE DETAILS</h2>
			<a class="pointer Closebtn2" onclick="closePopup('editProfilePopup')">x</a>
			<table border=1 align="center" class="protab" cellspacing="5" cellpadding="5" style="width:75%">
							
				<tr>
					<td>First Name</td><td><input type='text'  id='editfirstname' value="<?php echo $user->getFirstName(); ?>"></td>
				</tr>
				<tr>
					<td>Last Name</td><td><input type='text'  id='editlastname' value="<?php echo $user->getLastName();?>"></td>
				</tr>
					<tr>
					<td>Email</td><td><input type='text'  id='editemail' value="<?php echo $user->getEmail();?>"></td>
				</tr>	
				<tr>
					<td style="text-align:center" colspan="2">
						<button onclick='save()'id='save'>SAVE</button>&nbsp;
						<button onclick="closePopup('editProfilePopup')">CANCEL</button>&nbsp;
						<button  onClick="changePassword()">CHANGE PASSWORD</button>&nbsp;
					</td>
				</tr>
			</table>
			<?php
}

function changePassword($user)
	{
	?>
		<h2 class="center">PROFILE DETAILS</h2>
			<a class="pointer Closebtn2" onclick="closePopup('changePasswordPopup')">x</a>
			<table border=1 align="center" class="protab" cellspacing="5" cellpadding="5" style="width:75%">
				<tr>
					<td>Old Password</td>
					<td><input type='password' id='oldpass' value=""></td>
				</tr>
				
				<tr>
					<td>New Password</td>
					<td><input type='password'  id='newpass' value=""></td>
				</tr>
				<tr>
					<td>Confirm New Password</td>
					<td><input type='password'  id='cnewpass' value=""></td>
				</tr>
				<tr>
					<td style="text-align:center" colspan="2">
						<button onclick='change()'id='change'>SAVE</button>&nbsp;
						<button onclick="closePopup('changePasswordPopup')">CANCEL</button>						
					</td>
				</tr>
			</table>
<?php
	}


function updateProgress()
	{
	?>
		<h2 class="center">UPDATE PROGRESS</h2>
			<a class="pointer Closebtn2" onclick="closePopup('updateProgressPopup')">x</a>
			<table border=1 align="center" class="protab" cellspacing="5" cellpadding="5" style="width:75%">
				<tr>
					<td>Task Name</td>
					<td><input type='text' readonly=readonly id='taskname'  value=""></td>
						<input type='hidden'  id='taskid'  value="">
				</tr>
				
				<tr>
					<td>Percentage</td>
					<td><input type='text' id='percentage' maxlength='3' value="">%</td>
				</tr>
				<tr>
					<td style="text-align:center" colspan="2">
						<button onclick='progress()'id='change'>SAVE</button>&nbsp;
						<button onclick="closePopup('updateProgressPopup')">CANCEL</button>						
					</td>
				</tr>
				
			</table> <div id='updatemsg' class='no2'></div>
<?php
	}

}
?>